﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
using JModel;
using System.Linq;
public partial class aspnet_testPargrameDir_bock_Column_CX_Column_Temp_Edit : System.Web.UI.Page
{
    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    /// <summary>
    /// 数据操作
    /// </summary>
    DBEntities db = new DBEntities();


    /// <summary>
    /// 表名
    /// </summary>
    string Tab = "";

    /// <summary>
    /// 栏目名
    /// </summary>
    string Column_Name = "";

    int Rid = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PageLandX();
        }
    }


    protected void PageLand()
    {
        try
        {
            Rid = int.Parse(Request.QueryString["stid"].ToString().Trim());
            Tab = "RegUser";
            Column_Name = Rid.ToString();
            this.Title = "修改" + Column_Name + "的内容";
            Label1.Text = Column_Name;
            Label2.Text = Column_Name;
        }
        catch
        {
            TextData.Err("些页面不能直接访问");
            Response.End();
        }

    }

    /// <summary>
    /// 首次加载页面
    /// </summary>
    void PageLandX()
    {

        PageLand();

        var curRecrod = db.RegUser.FirstOrDefault(p => p.RegUser_LX == Rid);
        if (curRecrod != null)
        {
            Pic.Text = curRecrod.RegUser_Pic;
            email.Text = curRecrod.RegUser_Name;
            Contont.Text = curRecrod.RegUser_Contont;
            Explier.Text = curRecrod.RegUser_Explier;
            pwd.Text = curRecrod.RegUser_CreatefileName;
            Link.Text = curRecrod.RegUser_Link;

        }


    }


    /// <summary>
    /// 保存数据
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {

        PageLand();//得到应该有的参数

        var curRecrod = db.RegUser.FirstOrDefault(p => p.RegUser_LX == Rid);
        if (curRecrod != null)
        {
            curRecrod.RegUser_Pic = Pic.Text;
            curRecrod.RegUser_Name = email.Text;
            curRecrod.RegUser_Contont = Contont.Text;
            curRecrod.RegUser_Explier = Explier.Text;
            if (!string.IsNullOrEmpty(pwd.Text))
            {
                curRecrod.RegUser_CreatefileName = pwd.Text;
            }
            curRecrod.RegUser_Link = Link.Text;

            db.SaveChanges();
        }



        tt.Text = "修改 " + email.Text + " 成功";
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), Rid.ToString(), "<script>alert('" + tt.Text + "');window.close(); </script>", false);


    }
    /// <summary>
    /// 内容状态保存时发生
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void Page_SaveStateComplete(object sender, EventArgs e)
    {

        db.Connection.Close();
        db.Dispose();
    }


    public String IsShowElement()
    {
        string scripttext = "";
        // Pic 显示小图片
        try
        {
            if (Convert.ToBoolean(Request.QueryString["Pic"].ToString()))
            {
                scripttext += "document.getElementById(\"Pic\").style.display='';\r\n";
            }
            else
            {
                scripttext += "document.getElementById(\"Pic\").style.display='none';\r\n";
            }
        }
        catch
        {
            scripttext += "document.getElementById(\"Pic\").style.display='none';\r\n";
        }

        // Cont 显示内容
        try
        {
            if (Convert.ToBoolean(Request.QueryString["Cont"].ToString()))
            {
                scripttext += "document.getElementById(\"Cont\").style.display='';\r\n";
            }
            else
            {
                scripttext += "document.getElementById(\"Cont\").style.display='none';\r\n";
            }
        }
        catch
        {
            scripttext += "document.getElementById(\"Cont\").style.display='none';\r\n";
        }

        // Expiler 说明
        try
        {
            if (Convert.ToBoolean(Request.QueryString["Expiler"].ToString()))
            {
                scripttext += "document.getElementById(\"Expiler\").style.display='';\r\n";
            }
            else
            {
                scripttext += "document.getElementById(\"Expiler\").style.display='none';\r\n";
            }
        }
        catch
        {
            scripttext += "document.getElementById(\"Expiler\").style.display='none';\r\n";
        }


        // Crtfile 生成文件名 
        try
        {
            if (Convert.ToBoolean(Request.QueryString["Crtfile"].ToString()))
            {
                scripttext += "document.getElementById(\"Crtfile\").style.display='';\r\n";
            }
            else
            {
                scripttext += "document.getElementById(\"Crtfile\").style.display='none';\r\n";
            }
        }
        catch
        {
            scripttext += "document.getElementById(\"Crtfile\").style.display='none';\r\n";
        }

        // Sort 排序
        try
        {
            if (Convert.ToBoolean(Request.QueryString["Sort"].ToString()))
            {
                scripttext += "document.getElementById(\"Sort\").style.display='';\r\n";
            }
            else
            {
                scripttext += "document.getElementById(\"Sort\").style.display='none';\r\n";
            }
        }
        catch
        {
            scripttext += "document.getElementById(\"Sort\").style.display='none';\r\n";
        }

        // ShowLx 显示类型 
        try
        {
            if (Convert.ToBoolean(Request.QueryString["ShowLx"].ToString()))
            {
                scripttext += "document.getElementById(\"ShowLx\").style.display='';\r\n";
            }
            else
            {
                scripttext += "document.getElementById(\"ShowLx\").style.display='none';\r\n";
            }
        }
        catch
        {
            scripttext += "document.getElementById(\"ShowLx\").style.display='none';\r\n";
        }
        // linkxx 链接地址
        try
        {
            if (Convert.ToBoolean(Request.QueryString["linkxx"].ToString()))
            {
                scripttext += "document.getElementById(\"linkxx\").style.display='';\r\n";
            }
            else
            {
                scripttext += "document.getElementById(\"linkxx\").style.display='none';\r\n";
            }
        }
        catch
        {
            scripttext += "document.getElementById(\"linkxx\").style.display='none';\r\n";
        }

        return scripttext;
    }
}
